package com.ruoyi.product.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.product.domain.dto.WoRawDto;
import com.ruoyi.product.service.WoRawService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/woRaw")
public class WoRawController {
    @Autowired
    WoRawService woRawService;

    @PostMapping("/getWoRawByPage")
    public R export(@RequestBody WoRawDto materialDto)
    {
        return R.ok(woRawService.getWoRawByPage(materialDto));
    }

    @PostMapping("/addWoRaw")
    public R addTest(@RequestBody WoRawDto materialDto){
        woRawService.addWoRaw(materialDto);
        return R.ok("添加成功");
    }

    @PostMapping("/addWoRaws")
    public R addTest(@RequestBody List<WoRawDto> materialDto){
        woRawService.addWoRaws(materialDto);
        return R.ok("添加成功");
    }

    @PostMapping("/delWoRaw")
    public R delTest(@RequestBody WoRawDto materialDto){
        woRawService.delWoRaw(materialDto);
        return R.ok("删除成功");
    }

    @PostMapping("/updateWoRaw")
    public R updateTest(@RequestBody WoRawDto materialDto){
        woRawService.updateWoRaw(materialDto);
        return R.ok("锁定成功");
    }

    /**
     * 更新状态成功
     * @param materialDto
     * @return
     */
    @PostMapping("/updateWoRawStatus")
    public R updateWoRawStatus(@RequestBody WoRawDto materialDto){
        woRawService.updateWoRawStatus(materialDto);
        return R.ok("锁定成功");
    }


    @PostMapping("/updateWoRawActualLossValue")
    public R updateWoRawActualLossValue(@RequestBody List<WoRawDto> materialDto){
        woRawService.updateWoRawActualLossValue(materialDto);
        return R.ok("更新成功");
    }
}
